package com.colt.contentcenter.feighclient.fallback.factory;

import com.colt.contentcenter.domain.dto.messaging.UserUpdateBonusMsgDTO;
import com.colt.contentcenter.domain.dto.user.UserDTO;
import com.colt.contentcenter.feighclient.UserCenteFeighrClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @program: content-center
 * @description: fallbackFactory
 * @author: colt
 * @create: 2020-05-28 15:14
 **/
@Component
@Slf4j
public class UserFeignClientFallbackFactory  implements FallbackFactory<UserCenteFeighrClient> {

    @Override
    public UserCenteFeighrClient create(Throwable throwable) {
        return new UserCenteFeighrClient() {
            @Override
            public UserDTO findById(Integer id) {
                log.warn("远程调用降级限流了",throwable);
                UserDTO userDTO = new UserDTO();
                userDTO.setWxNickname("一个默认用户");
                return null;
            }

            @Override
            public UserDTO query(UserDTO userDTO) {
                return null;
            }

            @Override
            public UserDTO addBonus(UserUpdateBonusMsgDTO dto) {
                return null;
            }
        };
    }
}
